package com.ycq.testng.paramter;

import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.lang.reflect.Method;

public class DataProviderTest {

    @Test(dataProvider = "tt")
    public void testDataProvider(String name, int age) {
        System.out.println("name=" + name + ";age=" + age);
    }

    @DataProvider(name = "tt")
    public Object[][] providerData() {
        Object[][] o = new Object[][]{
                {"laoliu", 7},
                {"laoqi", 78},
                {"nima", 55}
        };
        return o;
    }


    @Test(dataProvider = "metohd")
    public void tset11(String name, int age) {
        System.out.println("test11111111name=" + name + ";age=" + age);
    }

    @Test(dataProvider = "metohd")
    public void tset22(String name, int age) {
        System.out.println("test2222222222name=" + name + ";age=" + age);
    }

    @DataProvider(name = "metohd")
    public Object[][] methodData(Method method) {
        Object[][] res = null;
        if (method.getName().equals("tset11")) {
            res= new Object[][]{
                    {"laoliu", 7}
            };
        }
        else if (method.getName().equals("tset22")){
            res=new Object[][]{
                    {"ca",78979},
                    {"hehe",6}
            };
            }
        return res;
        }

    }

